package frame.networks.viewers;

import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.SwingConstants;
import model.components.links.link.Link;
import model.components.networks.network.VirtualNetwork;
import model.components.nodes.node.Node;

import edu.uci.ics.jung.algorithms.layout.Layout;
import frame.MopraFrame;
import frame.networks.viewers.viewer.NetworkVisualizationViewer;

@SuppressWarnings("serial")
public class VirtualNetworksVisualizationViewersTabbedPane extends JTabbedPane
{
	private MopraFrame mopraFrame;
	public MopraFrame getFrame(){ return mopraFrame; }
	public void setFrame( MopraFrame mopraFrame ){ this.mopraFrame = mopraFrame; }
	
	public VirtualNetworksVisualizationViewersTabbedPane( MopraFrame mopraFrame )
	{
		this.setFrame( mopraFrame );
		
		this.setTabPlacement( SwingConstants.TOP );
		
		for( VirtualNetwork virtualNetwork: mopraFrame.getSimulator().getVirtualNetworks() )
			this.addVirtualNetworkTab( virtualNetwork );
	}
	
	public void addVirtualNetworkTab( VirtualNetwork virtualNetwork )
	{
		Layout< Node, Link > layout = virtualNetwork.getLayout();
		layout.setGraph( virtualNetwork.getGraph() );
		
		NetworkVisualizationViewer networkVisualizationViewer = new NetworkVisualizationViewer( layout, this.getFrame() );
		networkVisualizationViewer.setBackground( Color.WHITE );
		
		JPanel panel = new JPanel( new BorderLayout() );
		panel.add( networkVisualizationViewer );
		this.addTab( virtualNetwork.getName(), null, panel, null );
	}

}